package com.ruoyi.pidaijiData.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.pidaijiData.domain.plat.DataPidaijiPpzyl;
import com.ruoyi.pidaijiData.service.IDataPidaijiPpzylService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 皮带机跑偏保护作用力测试数据Controller
 * 
 * @author ruoyi
 * @date 2024-03-04
 */
@RestController
@RequestMapping("/pidaiji/ppzyl")
public class DataPidaijiPpzylController extends BaseController
{
    @Autowired
    private IDataPidaijiPpzylService dataPidaijiPpzylService;

    /**
     * 查询皮带机跑偏保护作用力测试数据列表
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:ppzyl:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataPidaijiPpzyl dataPidaijiPpzyl)
    {
        startPage();
        List<DataPidaijiPpzyl> list = dataPidaijiPpzylService.selectDataPidaijiPpzylList(dataPidaijiPpzyl);
        return getDataTable(list);
    }

    /**
     * 导出皮带机跑偏保护作用力测试数据列表
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:ppzyl:export')")
    @Log(title = "皮带机跑偏保护作用力测试数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataPidaijiPpzyl dataPidaijiPpzyl)
    {
        List<DataPidaijiPpzyl> list = dataPidaijiPpzylService.selectDataPidaijiPpzylList(dataPidaijiPpzyl);
        ExcelUtil<DataPidaijiPpzyl> util = new ExcelUtil<DataPidaijiPpzyl>(DataPidaijiPpzyl.class);
        util.exportExcel(response, list, "皮带机跑偏保护作用力测试数据数据");
    }

    /**
     * 获取皮带机跑偏保护作用力测试数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:ppzyl:query')")
    @GetMapping(value = "/{ppId}")
    public AjaxResult getInfo(@PathVariable("ppId") Long ppId)
    {
        return success(dataPidaijiPpzylService.selectDataPidaijiPpzylByPpId(ppId));
    }

    /**
     * 新增皮带机跑偏保护作用力测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:ppzyl:add')")
    @Log(title = "皮带机跑偏保护作用力测试数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataPidaijiPpzyl dataPidaijiPpzyl)
    {
        return toAjax(dataPidaijiPpzylService.insertDataPidaijiPpzyl(dataPidaijiPpzyl));
    }

    /**
     * 修改皮带机跑偏保护作用力测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:ppzyl:edit')")
    @Log(title = "皮带机跑偏保护作用力测试数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataPidaijiPpzyl dataPidaijiPpzyl)
    {
        return toAjax(dataPidaijiPpzylService.updateDataPidaijiPpzyl(dataPidaijiPpzyl));
    }

    /**
     * 修改皮带机跑偏保护作用力测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:ppzyl:remove')")
    @Log(title = "修改皮带机跑偏保护作用力测试数据", businessType = BusinessType.UPDATE)
    @PutMapping("/editPpzyl/{ppId}")
    @ApiOperation(value="修改皮带机跑偏保护作用力测试数据")
    public AjaxResult editPpzyl(@PathVariable Long ppId)
    {
        return toAjax(dataPidaijiPpzylService.updateDataPidaijiPpzylByPpId(ppId));
    }

    /**
     * 删除皮带机跑偏保护作用力测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:ppzyl:remove')")
    @Log(title = "皮带机跑偏保护作用力测试数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ppIds}")
    public AjaxResult remove(@PathVariable Long[] ppIds)
    {
        return toAjax(dataPidaijiPpzylService.deleteDataPidaijiPpzylByPpIds(ppIds));
    }
}
